package com.zzyk.main.service.impl;


import com.zzyk.main.mapper.SysPermissionDao;
import com.zzyk.main.model.pojo.RolePermission;
import com.zzyk.main.model.pojo.SysPermission;
import com.zzyk.main.model.vo.PermissionNode;
import com.zzyk.main.service.ISysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;

@Service
@Transactional
public class SysPermissionServiceImpl implements ISysPermissionService {

    @Autowired
    private SysPermissionDao sysPermissionDao;

    @Override
    public SysPermission getPermission(int permissionId) {
        return sysPermissionDao.getPermissionById(permissionId);
    }

    @Override
    public SysPermission getPermission(String permissionName) {
        return sysPermissionDao.getPermissionByName(permissionName);
    }

    @Override
    public List<SysPermission> getPermissionList(SysPermission sysPermission) {
        return sysPermissionDao.getPermissionList(sysPermission);
    }

    @Override
    public int addRolePermission(List<RolePermission> rolePermissionList) {
        return sysPermissionDao.addRolePermission(rolePermissionList);
    }

    @Override
    public int deleteRolePermission(RolePermission rolePermission) {
        return sysPermissionDao.deleteRolePermission(rolePermission);
    }

    @Override
    public int deleteRolePermissionByRoleId(int roleId) {
        return sysPermissionDao.deleteRolePermissionByRoleId(roleId);
    }

    @Override
    public Set<SysPermission> getPermissionSetByRoleId(int roleId) {
        return sysPermissionDao.getPermissionSetByRoleId(roleId);
    }

    @Override
    public PermissionNode getPermissionTree() {
        return sysPermissionDao.getPermissionRoot();
    }
}
